import MTX from "../../pictures/TX/MTX/MTX";
import turn from "../game/time/turn";
import GeZiManager from "../Manager/GeZiManager";
import QinManager from "../Manager/QinManager";
import { Message } from "../Message/Message";
import MessageCenter from "../Message/MessageCenter";
import CHF from "./CHF";
import realThing from "./realThing";
import { gif } from "./spineANDgif/gif";


const { ccclass, property } = cc._decorator;
@ccclass
export default class Qin extends realThing {
    @property(Number)
    type:number = 0;
    ZB: number = 0;
CX:boolean=false
    tu:gif=null
   nn:number=2
  
  start(): void {
    this.ghost == true;
   turn.Roo.push(this)
  }

 
 
  // 获取类型名称
  getQinType(ZB:number,TZB:number) {
   // console.log(GeZiManager.Tcharacter.ZB)
//3指数量，0指默认对象为触发者

GeZiManager.Tcharacter=null
MessageCenter.MakeSHMessage("AM",[TZB],1,GeZiManager.PCP.Pturn,"getOneC");
if (this.CX&&GeZiManager.Tcharacter) {
  



console.log(GeZiManager.Tcharacter.ZB)
console.log(this.ZB)

MessageCenter.MakeSHMessage('AM',[this.ZB],this.type,0,"qin+")
this.tu=GeZiManager.Tcharacter.getComponentInChildren(MTX).FuG
this.tu.timeArray=[56,34,45,45,56,56,56,56,56,34,45,45,56,56,56,56,56,34,45,45,56,56,56,56,56,34,45,45,56,56,56,56,56,34,45,45,56,56,56,56]
cc.find("Canvas/DituManager/New Node/AnimalManager").getComponent(QinManager).last=GeZiManager.PCP.ColortoN(GeZiManager.Tcharacter.color); 
console.log(GeZiManager.Tcharacter.color);
console.log(GeZiManager.PCP.ColortoN(GeZiManager.Tcharacter.color))
GeZiManager.shanchuALL(GeZiManager.qin,this);

GeZiManager.shanchuALL(GeZiManager.qins,this.ZB);//效果触发后将符删除
      GeZiManager.Tcharacter=null;
switch (this.type) {
  case 0:this.tu.moveToNextFrame(0,8,1)
    
    break;
    case 1:this.tu.moveToNextFrame(9,17,1)
    
    break;
    case 2:this.tu.moveToNextFrame(18,26,1)
    
    break;
    case 3:this.tu.moveToNextFrame(27,35,1)
    
    break;
  default:
    break;
}






setTimeout(() => {
  this.fadeOutAndDisappear(this.node,400)

},300);
}
  }
 


CXX(){
this.CX=true
this.node.children[0].active=true
this.node.getChildByName("ll").active=false
this.node.getChildByName("LC").active=false
this.node.getComponent(gif).changeF(this.type,1);
console.log(this.ZB)
this.zyx=2
GeZiManager.getQin(this.ZB,this.ZB)


}


roundPass(): void {
  console.log(this.ZB)
  this.nn--
  this.node.getChildByName("LC").getComponent(cc.Label).string=this.nn+""
  if (this.nn==0) {
    this.CXX()
    
  }
}

  ReceiveMessage(message: Message) {
    // 空方法，不做任何处理

  }








}